/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EntityBeans;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Keith Augustsson
 */
@Entity
@Table(name = "canbe")
@NamedQueries({@NamedQuery(name = "Canbe.findAll", query = "SELECT c FROM Canbe c"), @NamedQuery(name = "Canbe.findByTripNr", query = "SELECT c FROM Canbe c WHERE c.canbePK.tripNr = :tripNr"), @NamedQuery(name = "Canbe.findByOtherAirline", query = "SELECT c FROM Canbe c WHERE c.canbePK.otherAirline = :otherAirline"), @NamedQuery(name = "Canbe.findByOtherFlight", query = "SELECT c FROM Canbe c WHERE c.canbePK.otherFlight = :otherFlight")})
public class Canbe implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CanbePK canbePK;

    public Canbe() {
    }

    public Canbe(CanbePK canbePK) {
        this.canbePK = canbePK;
    }

    public Canbe(String tripNr, String otherAirline, String otherFlight) {
        this.canbePK = new CanbePK(tripNr, otherAirline, otherFlight);
    }

    public CanbePK getCanbePK() {
        return canbePK;
    }

    public void setCanbePK(CanbePK canbePK) {
        this.canbePK = canbePK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (canbePK != null ? canbePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Canbe)) {
            return false;
        }
        Canbe other = (Canbe) object;
        if ((this.canbePK == null && other.canbePK != null) || (this.canbePK != null && !this.canbePK.equals(other.canbePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EntityBeans.Canbe[canbePK=" + canbePK + "]";
    }

}
